package com.example.controller;


import com.example.common.result.Result;
import com.example.entity.vo.CopmaVo;
import com.example.entity.yifei.Copma;
import com.example.mapper.CopmaMapper;
import com.example.mapper.CopmbMapper;
import com.example.service.CopmaService;
import com.example.service.CopmbService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author LiangPandeng
 * @since 2024-02-28
 */
@Slf4j
@RestController
@RequestMapping("/api/copma")
@Api(tags = "客户基本信息相关接口")
public class CopmaController {
    @Resource
    private CopmaService copmaService;

    @Resource
    private CopmaMapper copmaMapper;

    @Resource
    private CopmbService copmbService;

    @Resource
    private CopmbMapper copmbMapper;

    @GetMapping("/list")
    @ApiOperation("查看客户信息列表Vo")
    public Result<List<CopmaVo>> listVo(){
       List<CopmaVo> list = copmaMapper.selectVolist();
        return Result.success(list);
    }

    @GetMapping("/listAll")
    @ApiOperation("查询全部客户信息列表")
    public Result<List<Copma>> listAll(){
        List<Copma> copmas = copmaMapper.selectAllList();
        return Result.success(copmas);
    }

    @GetMapping("/listAllCode")
    @ApiOperation("查询全部客户信息列表 编号或名称查询")
    public Result<List<Copma>> listAllCode(String code){
        List<Copma> copmaVoList = copmaMapper.selectAllListCode(code);
        return Result.success(copmaVoList);
    }

    @GetMapping("/copmaAndPurmaList")
    @ApiOperation("查询客户简称列表和供应商简称列表")
    public Result<List<String>> copmaAndPurmaList(){
        List<String> copmaAndPurmaSimpleName = copmaMapper.copmaAndPurmaSimpleName();
        return Result.success(copmaAndPurmaSimpleName);
    }

    @GetMapping("/copmaAndPurmaInfoList")
    @ApiOperation("根据名称查询客户简称列表和供应商简称列表")
    public Result<List<Map<String,String>>> copmaAndPurmaInfoList(@RequestParam(required = false) String name){
        return Result.success(copmaMapper.copmaAndPurmaInfoList(name));
    }
}
